#code:utf-8
import datetime
import time
import csv
from crawler import downloadnew
from bs4 import BeautifulSoup
import json
from pymongo import MongoClient
import urllib.parse
import re
import sys   
from MongoTiebaListQueue import MongoTiebaListQueue
import threading
import math
import requests
import io,sys


client=MongoClient('localhost',27017)
db=client.cache

  


if __name__ == '__main__':    
  
    with open("userdetail.csv","w",newline="",encoding="utf-8") as csvfile:
    #with open("xinsonguser_tieba.csv","ab+") as csvfile:
        writer = csv.writer(csvfile,dialect = ("excel"))
        writer.writerow(['用户名', '个人习惯','当前职业','教育程度','婚姻状态','性别','性格','体型','其他','小学','居住地','初中','出生地','生日','联系方式','大学','个人简介','血型','公司','高中'])
        for i in db.tiabuser1.find():
            data=[i['_id'].replace(",",'-').replace("，",'-'),
                i['个人习惯'],i['当前职业'],i['教育程度'],i['婚姻状态'],i['性别'],i['性格'],i['体型'],i['其他'],i['小学'],i['居住地'],i['初中'],i['出生地'],i['生日'],i['联系方式'],i['大学'],i['个人简介'],i['血型'],i['公司'],i['高中']]
            writer.writerow(data)
        
        csvfile.close()

  